<template>
    <div id="BPList">
        <body-container>
            <search-form-container @search="onSearch">
                <div slot="input" class="search-input-slot">
                    <el-select class="search-input-slot__options" size="small" v-model="selectDict.optionType">
                        <el-option value="title" label="项目名称"/>
                        <el-option value="createBy" label="创始人姓名"/>
                        <el-option value="phone" label="联系方式"/>
                    </el-select>
                    <el-input size="small" clearable class="search-input-slot__cmp" v-model="selectDict.keyWords"
                              placeholder="请输入"/>
                </div>
            </search-form-container>
            <vj-table :page-obj="pageObj" @loadTable="onSearch" :loading="loading" :cfg-list="cfgList"
                      :table-data="tableData">
                <template #action="{id}">
                    <text-button text="删除" @click="del(id)"/>
                </template>
            </vj-table>
        </body-container>
    </div>
</template>
<script lang="ts">
    import Vue, {ComponentOptions, VueConstructor} from "vue"
    import Component from 'vue-class-component'
    import BodyContainer from "@/components/layout/body-container.vue";
    import SearchFormContainer from "@/components/layout/search-form-conatiner.vue";
    import {Mixins, Ref} from "vue-property-decorator";
    import {TableMixin} from "@/plugins/mixins/table";
    import {requestByDelete, requestByGet, requestByPost} from "@/utils/request";
    import {formatOptions, groupBy, hookLoading, itemFromArr, updateCfgOption} from "vijay-util";
    import TextButton from "@/components/basic/text-button.vue";
    import {CapitalBPTB, PuzzleRecordTB} from "@/config/table";
    import {PuzzleRecordSH} from "@/config/search";

    export const title = "BP管理";
    @Component({
        components: {TextButton, SearchFormContainer, BodyContainer}
    })
    export default class BPList extends Mixins(TableMixin) implements ComponentOptions<Vue> {
        name = "BPList"
        cfgList = CapitalBPTB;
        @hookLoading()
        async onSearch(pageNo?, pageSize?) {
            const params = Object.assign({pageNo, pageSize}, this.selectForm, this.searchForm);
            const res = await requestByGet(`qqc/qqcBpmanage/list`, params);
            this.tableData = res.records;
            return res;
        }
        async del(id) {
            await requestByDelete(`qqc/qqcBpmanage/delete`, {id});
            this.$message.success("操作成功！");
            return this.onSearch();
        }
        created() {
            this.onSearch();
        }
    }
</script>

<style scoped lang="scss">
    @import "~assets/common.scss";
    @import "~assets/scss/variables.scss";
    #BPList {
    }
</style>
